// mole   top: 70%;
const button = document.querySelector('button')
const mole = document.querySelectorAll('.mole')
const game = document.querySelector('.game')
const score = document.querySelector('.score')
let iten = 0
button.addEventListener('click', function () {
    score.innerHTML = 0
    iten = 0
    button.disabled = true
    let i = 0
    let data = setInterval(function () {
        i++
        console.log(i);
        let index = Math.floor(Math.random() * mole.length)
        let obj = []
        obj.push(index)
        mole[index].style.top = 0
        let disappear = setTimeout(function () {
            mole[index].style.top = '70%'
        }, 1000)
        if (i >= 6) {
            alert('时间到')
            button.disabled = false
            clearInterval(data)
        }
    }, 1000)
})

const moleYc = document.querySelectorAll('.mole')

moleYc[0].addEventListener('click', function () {
    mole[0].style.top = '70%'
    iten++
    score.innerHTML = iten
})
for (let i = 0; i < moleYc.length; i++) {
    moleYc[i].addEventListener('click', function () {
        mole[i].style.top = '70%'
        iten++
        score.innerHTML = iten
    })
}
